from flask import Flask, after_this_request

app = Flask(__name__)


@app.route('/')
def index():
    return '<h3>Testing Hook Function</h3>'


@app.route('/test')
def test():

    @after_this_request
    def hook_after_this_req(resp):
        print('----> after_this_request, after test()')
        return resp

    print('----> view function: test()')
    return "test"


@app.before_first_request
def hook_before_first_req():
    print('----> hook: before_first_request')


@app.before_request
def hook_before_req():
    print('----> hook: before_request')


@app.after_request
def hook_after_req(resp):
    print('----> hook: after_request')
    return resp


@app.teardown_request
def hook_teardown_req(resp):
    print('----> hook: teardown_request')
    return resp
